#ifndef _TW_WATER_H_
#define _TW_WATER_H_
#include <d3dx9.h>

class TwWaterShader;
class TwTexture;

class TwWater 
{
public:
	struct VERTEX
	{
		D3DXVECTOR3 pos;
		float u, v;

		static const DWORD FVF = D3DFVF_XYZ | D3DFVF_TEX1;
	};

public:
	TwWater();
	virtual ~TwWater();

	bool Create(const D3DXVECTOR3& pos, float width, float length);
	bool BeginScene();
	void EndScene();

	void Render(int t);
	void DrawPrimitive();

protected:
	bool CreateShader();

protected:
	TwWaterShader*		m_mShader;

	TwTexture*			m_mWaveTex;

	IDirect3DTexture9*	m_mEnvTex;
	IDirect3DSurface9*	m_mEnvSurface;
	IDirect3DSurface9*	m_mOldSurface;

	D3DXPLANE			m_mPlane;
	D3DXVECTOR3			m_mPos;
	float				m_mWidth;
	float				m_mLength;

	VERTEX				m_mVertices[4];
};
#endif